﻿@inject IUserService _userService


@if (Model.Positions.Any(s => s.Users.Any()))
{
    <CnGalWebSite.Components.Containers.MasaTitleContainer Title="应征创作者" Icon="@IconType.Flag.ToIconString()" Class="mb-4" Collapable Outline>
     <MDCard Class="mb-4">
         <MTabs Value="Model.TabIndex" IconsAndText Grow CenterActive ValueChanged="TabValueChanged">
                 <MTab Value="0">
                     全部<MIcon>@IconType.Users.ToIconString()</MIcon>
                    </MTab>
                    <MTab Value="1">
                        已选定<MIcon>@IconType.Check.ToIconString()</MIcon>
                    </MTab>
                </MTabs>
            </MDCard>
            <MTabsItems Value="Model.TabIndex">
                <MTabItem Value="0">
                    @foreach (var item in Model.Positions.Where(s => s.Users.Any()))
                {
                    <CnGalWebSite.Components.Containers.MasaTitleContainer Title="@item.GetPositionName()" Icon="@item.GetPositionIcon()" Collapable Outline>
                     @foreach (var info in item.Users)
                        {
                            <PositionUserCard Model="info" Creator="@(_userService.UserInfo.Id==Model.CreateUser.Id)" OnChanged="OnChanged" Id="Model.Id" />
                        }
                    </CnGalWebSite.Components.Containers.MasaTitleContainer>
                }
            </MTabItem>
            <MTabItem Value="1">
                @foreach (var item in Model.Positions.Where(s => s.Users.Any(s => s.Passed == true)))
                {
                    <CnGalWebSite.Components.Containers.MasaTitleContainer Title="@item.GetPositionName()" Icon="@item.GetPositionIcon()" Collapable Outline>
                     @foreach (var info in item.Users.Where(s => s.Passed == true))
                        {
                            <PositionUserCard Model="info" Creator="@(_userService.UserInfo.Id==Model.CreateUser.Id)" OnChanged="OnChanged" Id="Model.Id" />
                        }
                    </CnGalWebSite.Components.Containers.MasaTitleContainer>
                }
                @if (!Model.Positions.Any(s => s.Users.Any(s => s.Passed == true)))
                {
                    <NotFoundCard Fill />
                }
            </MTabItem>
        </MTabsItems>
    </CnGalWebSite.Components.Containers.MasaTitleContainer>
}


@code {
    [Parameter]
    public ProjectViewModel Model { get; set; }
    [Parameter]
    public EventCallback OnChanged { get; set; }

    public void TabValueChanged(StringNumber index)
    {
        if (index != null)
        {
            Model.TabIndex = index.ToInt32();
        }
    }
}
